<!DOCTYPE html>
<html>
<?php
	session_start();
	include "db_function.php";
	if(!isset($_SESSION['uid'])){
		header("Location:./login.php");
	}else{
?>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link media="all" href="./css/one-debug.css" rel="stylesheet">
	<link media="all" href="css/main.css" type="text/css" rel="stylesheet"/>
	<script type=""text/javascript src="./js/jq/jquery-1.8.3.js"></script>
	<script type=""text/javascript src="./js/my.js"></script>
</head>
<body>
	<div class="wrapper">
		<div class="head-area">
			<h1>
				<a href="./index.php" class="head_area">GuoBa留言本</a>
			</h1>
			<span class="ctr-bar">
				欢迎: <?php echo $_SESSION['username']; ?>|<a href='logout.php'>退出</a>
			</span>
			<div class="clear"></div>
		</div>
		
		<div class="ui-nav ui-nav-nosub">
	  		<ul class="ui-nav-main">
		   		<li class="ui-nav-item">
		     		<a href="index.php">看帖</a>
	    		</li>
	    		<li class="ui-nav-item">
		     		<a href="showpost.php">发帖</a>
	    		</li>
	    	</ul>
	    </div>
		<div class="content-area">			 
	<?php
	 	$post_arr=get_post($_GET['pid']);
	 	$cmt_list_arr=get_comment_list($_GET['pid']);
	 ?>

			<div class="ui-box">
		   		<div class="ui-box-head">
		        	<h3 class="ui-box-head-title">标题</h3>
		        	<span class="ui-box-head-text"><?=$post_arr['title']?></span>
		        	<a href="#" class="ui-box-head-more"></a>
		   		</div>
		    	<div class="ui-box-container">
			        <div class="ui-box-content">发布时间：<?=$post_arr['creat_time']?>|作者：<?=get_username($_SESSION['uid'])?> 
			        </div>
		   		</div>
		    	<div class="ui-box-container">
			        <div class="ui-box-content"><?=$post_arr['contents']?>
			        </div>
		   		</div>
			</div>
		<div class="commets">
			

			<form action="./commentbackend.php?pid=<?php echo $_GET['pid']?>" method="post" class="ui-form">
				<div class="ui-form-item">
					<label for="" class="ui-label">
	                	<span class="ui-form-required">*</span>回复帖子
	          		</label>
					<textarea name="content" cols="100" rows="5" class="ui-input"></textarea>
				</div>
				<div class="ui-form-item">
					<input type="submit" name="sub" value="     立即回复     " class="ui-input"/>
				</div>
			</form>
			<div class="ui-table-container">
		        <table class="ui-table"><!-- 可以在class中加入ui-table-inbox或ui-table-noborder分别适应不同的情况 -->
		            <thead>
		                <tr>
		                    <th>用户</th>
		                    <th>评论内容</th>
		                </tr>
		            </thead>
		            <tbody>
		                <?php 
		                if($cmt_list_arr !== null){
		               		foreach ($cmt_list_arr as $cmt_num => $comment):
		                ?>
		                <tr class="ui-table-split">
		                    <td><?php echo get_username($comment['uid']);?></td>
		                    <td><?=$comment['content']?></td>
		                </tr>         
		            <?php endforeach;
		        		}
}
		            ?>
		            </tbody>
		            <tfoot>
		            </tfoot><!-- 表尾可选 -->
		        </table>
	    	</div>
		</div>
	 </div>
</body>
</html>